﻿@model Host.Models.RegisterModel
 
@{
    ViewBag.Title = "Register";
}

<h2>Create a new user account.</h2>
<p style="width:80%; padding-left:30px; ">
    Use the form below to create a new user account. The  user account needs to be connected to a role for you to be able to use the system, passwords are required to be a minimum of @Membership.MinRequiredPasswordLength characters in length.
</p>



<script type="text/javascript">
    $(function () {
        $("input:submit").button();
        $("input:checkbox").change(function () {
            if (this.checked) {
                var checked = this.value;
                $("input:checkbox").each(function () {
                    if (this.value == checked) {
                    } else {
                        $(this).attr("disabled", true);
                    }
                })
                } else { $("input:checkbox").each(function () { $("input:checkbox").removeAttr("disabled"); }) }
        });
    });
</script>

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.")
    <div>
        <fieldset>
            <legend>Account Information</legend>

            <div class="editor-label">
                @Html.LabelFor(m => m.UserName)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.UserName)
                @Html.ValidationMessageFor(m => m.UserName)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.Email)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Email)
                @Html.ValidationMessageFor(m => m.Email)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.Password)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.Password)
                @Html.ValidationMessageFor(m => m.Password)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.ConfirmPassword)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.ConfirmPassword)
                @Html.ValidationMessageFor(m => m.ConfirmPassword)
            </div>
            <br />
            <div >
                <table id="roles" runat="server">
                <thead style="font-size:1.2em; color:Black; font-weight:bold;">Membership Roles</thead>
                @foreach (var d in Roles.GetAllRoles())
                { 
                    <tr><td style="width:200px;">
                        @Html.Label("", d)
                    </td>
                    <td>
                         <input type="checkbox"  name="UserRoles" value="@d" /> 
                        </td>
                    </tr>
                }
                </table>

            </div>
            <p>
                <input type="submit" value="Register" />
            </p>
        </fieldset>
    </div>
}
